<?php

class Kd_Html_Grid_Cell_Link extends Kd_Html_Grid_Cell_Text {

    private $_urlFormat = '';
    private $_url = '';
    private $_target = '';

    public function __construct(){
        parent::__construct();
        $this->templateName = 'grid/cell/link';
    }

    public function getTarget(){
        return $this->_target;
    }

    public function setTarget($value){
        $this->_target = $value;
        return $this;
    }

    public function getUrl(){
    	return $this->_url;
    }
    public function setUrl($value){
    	$this->_url = $value;
    	return $this;
    }

    public function getUrlFormat(){
        return $this->_urlFormat;
    }
    public function setUrlFormat($value){
        $this->_urlFormat = $value;
        return $this;
    }

    public function getCellLinkUrl(){
        return Kd_Util_String::format($this->getUrl(), $this->getGrid()->getCurrentRow());
    }

    protected function render(){
        $target = $this->getTarget()? ' target="'.$this->getTarget().'"': '';
        return '<a'.$target.' href="'.$this->getCellLinkUrl().'"><span>'.$this->getCellText().'</span></a>';
    }
}